using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[Serializable]
public class TimedVehicleStealEvent : VehicleStealEvent, ITimedEvent
{
	public float neededSteals = 5f;

	public float neededTime = 60f;

	public bool disableIfAchieved = true;

	public bool achieved;

	public bool IfEvent(VehicleStealInfo newSteal, List<VehicleStealInfo> vehicleStealList)
	{
		if (achieved)
		{
			return false;
		}
		if (neededVehicle != VehicleType.Non && newSteal.vehicleType != neededVehicle)
		{
			return false;
		}
		int num = 1;
		foreach (VehicleStealInfo vehicleSteal in vehicleStealList)
		{
			if ((neededVehicle == VehicleType.Non || vehicleSteal.vehicleType == neededVehicle) && newSteal.time - vehicleSteal.time <= neededTime)
			{
				num++;
				if ((float)num == neededSteals)
				{
					return true;
				}
			}
		}
		return false;
	}

	public IEnumerator DisableForTime()
	{
		AddToAchidedList();
		if (disableIfAchieved)
		{
			achieved = true;
		}
		yield return new WaitForSeconds(neededTime);
		Reset();
	}

	public void AddToAchidedList()
	{
		GameplayEventsManager.instance.allTimedEvents.Add(this);
		BCWDebug.Log("allTimedEvents.Count = " + GameplayEventsManager.instance.allTimedEvents.Count + "    WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
	}

	public void Reset()
	{
		achieved = false;
	}
}
